//+--------------------------------------------------------------------
//| Copyright(c) 2012 - an.vuongngocduy					
//| This file is a part of Compact Game Engine (CGE)	
//+--------------------------------------------------------------------
#ifndef __CGE_COLOR_H__
#define __CGE_COLOR_H__

#include "cgeCommons.h"
#include "cgeMath.h"

using namespace cge::std;

namespace cge
{
	namespace gfx
	{
		/// Represent RGBA color
		class Color
		{
		public:
			union F32HSB
			{
				f32 HSB[3];
				struct { f32 Hue, Saturation, Brightness; };
			};

			union F32RGBA
			{
				f32 RGBA[4];
				struct { f32 Red, Green, Blue, Alpha; };
			};

		public:
			/// Default constructor
			Color();

			/// Construct new color from specified color components
			Color(u8 r, u8 g, u8 b, u8 a);

			/// Construct new color from integer represent a RGBA color
			Color(u32 rgba);

			/// Destructor
			~Color();

			/// Set color value
			void Set(u8 r, u8 g, u8 b, u8 a);

			/// Set color value
			void Set(u32 rgba);

			/// Test whether color is transparent or not
			b8 IsTransparent() const;

			/// Init color from integer represent A8R8G8B8 color
			Color& FromARGB(u32 argb);

			/// Convert to A8R8G8B8 color
			u32 ToARGB() const;

			/// Init the values of current color from float values
			Color& FromFloats(F32RGBA rgba);

			/// Convert the values of current color to float values
			F32RGBA ToFloats() const;

			/// Init color's values from Hue, Saturation and Brightness
			Color& FromHSB(F32HSB hsb);

			/// Convert color's values to Hue, Saturation and Brightness
			F32HSB ToHSB() const;

			/// Check whether 2 colors are the same
			b8 operator == (const Color& col);

			/// Check whether 2 colors are different
			b8 operator != (const Color& col);

		public:
			union
			{
				struct
				{
					u8 Alpha, Blue, Green, Red;
				};
				u32 RGBA;
			};
		};

	}
}

#endif//__CGE_COLOR_H__